package com.cjm.one.goods.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.constant.SecurityConstants;
import com.cjm.one.common.constant.ServerConstants;
import com.cjm.one.common.result.Result;
import com.cjm.one.goods.client.fallback.GoodsSKuClientFallback;
import com.cjm.one.model.goods.dto.StockDeductionDTO;
import com.cjm.one.model.goods.dto.StockRevertDTO;
import com.cjm.one.model.goods.entity.GoodsCart;
import com.cjm.one.model.goods.entity.GoodsSku;
import com.cjm.one.model.goods.enums.SortStrategyEnum;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = ServerConstants.SERVER_ONE_GOODS,fallback = GoodsSKuClientFallback.class)

public interface GoodsSKuClient {

    @GetMapping("/app/goods/sku/list")
    @Operation(summary = "分页查询")
    Result<Page<GoodsSku>> pageList(@RequestParam(name = "current",defaultValue = "1") Long current,
                                           @RequestParam(name = "size",defaultValue = "10") Long size,
                                           @RequestParam(name = "categoryId", required = false) Long categoryId,
                                           @RequestParam(name = "name", required = false) String name,
                                           @RequestParam(name = "SortStrategy", required = false) SortStrategyEnum strategyEnum);
    @GetMapping("/app/goods/sku/ByCategoryId/list")
    @Operation(summary = "根据分类查询")
    Result<Page<GoodsSku>> pageListByCategoryId(@RequestParam(name = "categoryId", required = true) Long categoryId,
                                                       @RequestParam(name = "current",defaultValue = "1") Long current,
                                                       @RequestParam(name = "size",defaultValue = "10") Long size);

    @GetMapping("/app/goods/sku/coupon/list")
    @Operation(summary = "获取限定优惠商品")
    Result<Page<GoodsSku>> getSkuCoupon(@RequestParam("ids") Long[] ids);
    
    /**
     * @description: 扣减库存
     * @author: cjm 
     * @date: 2025/3/30 15:15
     * @param: [ids]
     * @return: com.cjm.one.common.result.Result<java.lang.Boolean>
     **/
    @PostMapping("/app/goods/sku/deduction/stock")
    @Operation(summary = "扣减库存")
    Result<Boolean> deductionStock(@RequestBody List<StockDeductionDTO> deductionList, @RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);
    /**
     * @description: 回滚库存
     * @author: cjm
     * @date: 2025/3/30 16:48
     * @param: [ids]
     * @return: com.cjm.one.common.result.Result<java.lang.Boolean>
     **/
    @PostMapping("/app/goods/sku/revert/stock")
    @Operation(summary = "回滚库存")
    Result<Boolean> revertStock(@RequestBody List<StockRevertDTO> stockRevertDTOS, @RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);
}
